package entity.weapons;

import java.awt.Graphics2D;

public class WeaponsInventory extends Inventory<Weapon>
{
	//store the index of the weapon we're on
	private int index;
	
	public WeaponsInventory()
	{
		super();
		index = 0;
	}
	
	/**
	 * cycle to the next weapon and return it
	 * @return
	 */
	public Weapon next()
	{
		if(index >= getItems().size()-1)
		{
			index = 0;
		}
		else
			index++;
		
		//possible to have an inventory of 0
		if(getItems().size() != 0)
			return getItems().get(index);
		return null;
	}
	
	/**
	 * cycle to the previous weapon and return it1
	 * @return
	 */
	public Weapon prev()
	{
		if(index <= 0)
			index = getItems().size()-1;
		else
			index--;
		
		if(getItems().size() != 0)
			return getItems().get(index);
		return null;
	}
	
	/**
	 * Return the current weapon
	 * @return
	 */
	public Weapon currentWeapon()
	{
		return getItems().get(index);
	}
	
	/**
	 * return a certain weapon
	 * @param i - index of the weapon
	 * @return
	 */
	public Weapon moveTo(int i)
	{
		if(getItems().size() == 0)
			return null;
		if(i>=0 && i< getItems().size())
		{
			index = i;
			return getItems().get(i);
		}
		return null;
	}

	@Override
	public void render( Graphics2D g )
	{
	}
}
